# 导入webdriver
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy
import time
from time import sleep
import unittest
from datetime import datetime
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class Base(unittest.TestCase):
    def __init__(self):
    # 初始化参数
        desired_caps = {
            'platformName': 'Android',  # 被测手机是安卓
            'platformVersion': '12',  # 手机安卓版本
            'deviceName': 'huawei_meta_50',  # 设备名，安卓手机可以随意填写
            'appPackage': 'com.metaso',  # 启动APP Package名称   com.metaso
            'appActivity': '.main.ui.activity.SplashActivity',  # 启动Activity名称
            'unicodeKeyboard': True,  # 使用自带输入法，输入中文时填True
            'resetKeyboard': True,  # 执行完程序恢复原来输入法
            'noReset': True,  # 不要重置App，如果为False的话，执行完脚本后，app的数据会清空，比如你原本登录了，执行完脚本后就退出登录了
            'newCommandTimeout': 6000,#超时6000
            'automationName': 'UiAutomator2'
        }
        # 连接Appium Server，初始化自动化环境
        options = UiAutomator2Options().load_capabilities(desired_caps)
        self.driver = webdriver.Remote(command_executor='http://localhost:4723/wd/hub', options=options)
        #driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
        self.driver.implicitly_wait(2)#配置全局隐式等待时长
    #登陆
    def login(self,name,password):
        login_btn = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_login") #首页按钮
        if login_btn:
            print("···开始执行登陆···")
            #print(self.driver.find_element(AppiumBy.ID,"com.metaso:id/tv_login"))
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/tv_login").click()#点登陆
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/btnPasswordLogin").click()#账号密码登陆
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/et_account").send_keys(name) #输入账号
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/et").send_keys(password) #输入密码
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/btn_login").click()#账号密码登陆
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/cmicAgreeBtn").click()#点击统一协议
            
            login_btn = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_login")#首页按钮
            if not login_btn:
                print("登陆校验1：首页登陆按钮不存在")
                self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_user").click()#点我的
                query_num = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_user_query_num")
                if query_num:
                    print("登陆校验2：我的里面额度存在")
                    print("···登陆成功···")
                    self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_home").click()#回到首页
                else:
                    print("校验不成功")
            else:
                print("校验不成功")
        else:
            print("登陆按钮不存在，当前为登陆状态")
        sleep(3)



    #退出登陆
    def login_out(self):
        print("···开始执行退出登陆···")
        sleep(1)
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_user").click()#点我的
        
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/ll_header").click()#点header

        self.driver.find_element(AppiumBy.ID,"com.metaso:id/tv_logout").click()#点退出登陆

        self.driver.find_element(AppiumBy.ID,"com.metaso:id/tv_apply_return").click()#点确定

        login_btn = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_login") #首页按钮
        if login_btn:
            print("退出登陆校验1：首页登陆按钮存在")
            self.Bottom_Btn_Click("账户")
            login2_btn = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_login") #我的里面的登陆/注册按钮
            if login2_btn:
                print("退出登陆校验1：我的里面顶部登陆注册按钮存在")
                print("···退出登陆成功···")
            else:
                print("退出登录失败")
        else:
            print("退出登陆失败")
        self.Bottom_Btn_Click("首页")

    #顶部点返回按钮
    def Return_Btn_Up(self):
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_left_icon").click()
    #底部点返回按钮
    def Return_Btn_Down(self):
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_back").click()
    #滑动到最底部
    def Swipe_to_down(self):
        share = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_share") #底部分享按钮
        while(len(share) == 0):
            self.driver.swipe(500, 1500, 500, 300, 500)
            share = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_share") #底部分享按钮
    #检查我的页面的所有选项按钮是否存在
    def Check_my(self):
        print("···开始检查我的页面···")
        sleep(1)
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_user").click()#点我的
        feedback = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_feedback")#用户反馈
        if not feedback:
            print("用户反馈不存在")
        else:
            print("···校验用户反馈···")
            feedback[0].click()
            fankui = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_title") #用户反馈
            if len(fankui) ==0:
                print("用户反馈页面存在异常")
            print("···用户反馈校验结束···")
            self.Return_Btn_Up()
        search_history = self.driver.find_elements(AppiumBy.ID,"cl_search_history")#搜索记录
        if not search_history:
            print("搜索记录不存在")
        jb = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_jb")#举报
        if not jb:
            print("举报不存在")
        theme = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_theme")#主题设置
        if not theme:
            print("主题设置不存在")
        language = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_language")#输出语言
        if not language:
            print("输出语言不存在")
        extension = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_extension")#延伸阅读
        if not extension:
            print("延伸阅读不存在")
        else:
            print("开始校验延伸阅读开关")
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/extensionSwtich").click()#关闭延伸阅读
            self.Bottom_Btn_Click("首页")
            sleep(1)
            souye = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView")
            if len(souye) !=11:
                print("首页没例子")
                self.Bottom_Btn_Click("账户")
            else:
                self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView")[5].click() #到首页搜索第一个例子
                self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)
                self.Swipe_to_down()    #搜完之后往下滑动找延伸阅读按钮
                yansheng_read = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_extension_expand")
                if len(yansheng_read) == 0:
                    print("延申阅读关闭成功")
                    self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_mine").click()#返回首页
                    self.Bottom_Btn_Click("账户")
                    self.driver.find_element(AppiumBy.ID,"com.metaso:id/extensionSwtich").click()
                else:
                    print("延申阅读关闭失败")
                    self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_mine").click()#返回首页
                    self.Bottom_Btn_Click("账户")

        example = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_example")#首页样例
        if not example:
            print("首页样例不存在")
        else:
            print("关闭首页样例")
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/exampleSwtich").click()#关闭首页样例按钮
            self.Bottom_Btn_Click("首页")
            souye = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView")
            print(len(souye))
            if len(souye) == 12:
                print("首页样例关闭失败")
                self.Bottom_Btn_Click("账户")
            else:
                print("首页样例关闭成功")
                self.Bottom_Btn_Click("账户")
                self.driver.find_element(AppiumBy.ID,"com.metaso:id/exampleSwtich").click()#开启首页样例

        history = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_history")#最近使用
        if not history:
            print("最近使用不存在")
        else:
            print("···开始校验最近使用按钮···")
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/historySwtich").click()#关闭最近使用
            self.Bottom_Btn_Click("首页")
            zuijing = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_history")#s首页最近
            if len(zuijing) > 0:
                print("最近按钮关闭失败")
            else:
                print("最近按钮关闭成功")
            print("···最近使用按钮校验完成···")
            self.Bottom_Btn_Click("账户")
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/historySwtich").click()#开启最近使用

        shock = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_shock")#震动反馈
        if not shock:
            print("震动反馈不存在")
        set_default = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_set_default")#设为默认
        if not set_default:
            print("设为默认不存在")
        else:
            set_default[0].click()
            self.Return_Btn_Up()
        privacy_policy = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_privacy_policy")#隐私策略
        if not privacy_policy:
            print("隐私策略不存在")
        else:
            privacy_policy[0].click()
            self.Return_Btn_Up()

        privacy_policy2 = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_privacy_policy2")#用户协议
        if not privacy_policy2:
            print("用户协议不存在")
        else:
            privacy_policy2[0].click()
            self.Return_Btn_Up()
        self.driver.swipe(500, 1500, 500, 1000, 500)

        current_version = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_current_version")#当前版本
        if not current_version:
            print("当前版本不存在")
        about_us = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/cl_about_us")#关于
        if not about_us:
            print("关于不存在")
        else:
            sleep(1)# 右侧的滑动条影响点击
            about_us[0].click()
            self.Return_Btn_Up()
            
        self.driver.swipe(600, 1000, 600, 1500, 500)
        # if feedback and search_history and jb and theme and language and extension and example and history and shock and set_default and privacy_policy and privacy_policy2 and current_version and about_us:
        #     print("我的页面所有按钮都存在")
        # else:
        #     print("我的页面有按钮不存在")
        print("···我的页面检查完成···")


    #点击底部的三个按钮，首页，书架，我的。
    def Bottom_Btn_Click(self,btn):
        if btn == "首页":
            try:
                self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_mine").click()
            except:
                self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_home").click()
        elif btn == "书架":
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_bookshelf").click()
        elif btn == "账户" or btn =="我的":
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_user").click()
        else:
            print("参数错误")
    
    #等待搜索结果出现

    def Wait_Tag_Show(self,tag,time_out):
        try:
            # 设置最长等待时间为10秒
            element = WebDriverWait(self.driver,time_out).until(EC.presence_of_element_located((AppiumBy.ID, tag)))
            print("搜索完成")
        except:
            print("元素未在规定时间内出现")
            print("返回首页")
            self.Bottom_Btn_Click("首页")
            sleep(2)
    def Clear_Search(self):
        zuijing = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_history") #首页的最近
        if zuijing:  #清除最近的历史纪录
            zuijing[0].click() #点击最近
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/tv_right").click() #清空
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/tv_apply_return").click() #确定
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_left_icon").click()#返回首页
        else:
            print("未找到最近历史记录按钮")
        sleep(0.5)
    
    #未登录的时候搜索首页例子
    def Unlogin_serach(self):
        login_btn = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_login") #首页按钮
        if not login_btn:
            self.login_out()
        self.Clear_Search() #先清除历史记录
        souye = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView") #首页样例
        print("未登录，搜索"+str(len(souye)))
        for i in range(5): #
            souye[5+i].click()
            self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
            self.Return_Btn_Down()
        zuijin = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_history") #首页的最近
        zuijin[0].click()
        count_serach = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.view.ViewGroup") #计算首页的例子的个数
        print("最近使用里面的viewGroup个数"+str(len(count_serach))) #原本就有2个ViewGroup所以结果会多两个
        if len(count_serach) != (5+2):
            print("历史记录个数错误")
        else:
            print("首页例子，测试完毕，个数正确")
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_left_icon").click()#返回首页
        self.Clear_Search()
        moshi = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView")#切换到简洁模式
        moshi[2].click()
        print("···············简洁模式···············")
        self.Serach_Scope("全网","全网")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        self.Serach_Scope("文库","文库")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        self.Serach_Scope("学术","学术")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        self.Serach_Scope("播客","播客")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        print("···············深入模式···············")
        moshi = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView")#切换到深入模式
        moshi[3].click()
        self.Serach_Scope("全网","全网")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        self.Serach_Scope("文库","文库")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        self.Serach_Scope("学术","学术")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        self.Serach_Scope("播客","播客")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        print("···············研究模式···············")
        moshi = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView")#切换到研究模式模式
        moshi[4].click()
        self.Serach_Scope("全网","全网")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        self.Serach_Scope("文库","文库")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        self.Serach_Scope("学术","学术")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        self.Serach_Scope("播客","播客")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)#等待搜索结果出现
        self.Return_Btn_Down()
        self.Clear_Search()

    
    #搜索范围
    def Serach_Scope(self,Scope,content):
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_down").click() #点范围下拉框
        if Scope =="全网":
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/cl_all").click() #全网
        elif Scope =="文库":
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/cl_wk").click() #文库
        elif Scope =="学术":
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/cl_xs").click() #学术
        elif Scope =="播客":
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/cl_bk").click() #播客
        else:
            print("参数错误")
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/edit_text").send_keys(content) #输入框输入内容
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_send").click() #发送
    #用户反馈
    def user_feedback(self):
        self.Bottom_Btn_Click("我的")
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/cl_feedback").click()#点用户反馈
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/et_content").send_keys("用户反馈测试测测试测试")#输入文字
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/btn_commit").click()#提交
    #登录之后搜索
    def Serach(self,Scope,moshi,content):
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_down").click() #点范围下拉框
        if Scope =="全网":
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/cl_all").click() #全网
        elif Scope =="文库":
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/cl_wk").click() #文库
        elif Scope =="学术":
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/cl_xs").click() #学术
        elif Scope =="播客":
            self.driver.find_element(AppiumBy.ID,"com.metaso:id/cl_bk").click() #播客
        else:
            print("参数错误")
        moshi_t = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView")#切换模式 简洁为2.深入为3.研究为4
        if moshi == "简洁":
            moshi_t[2].click()
        elif moshi =="深入":
            moshi_t[3].click()
        elif moshi =="研究":
            moshi_t[4].click()
        else:
            print("模式输入错误")
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/edit_text").send_keys(content) #输入框输入内容
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_send").click() #发送
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",20)
        linke_num = self.driver.find_element(AppiumBy.ID,"com.metaso:id/tv_link_num")#来源数目_顶部
        re_text = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView") #文章title的索引为0，全网为1，文库为2，学术为3，播客为4
        if Scope =="全网":
            print(re_text[1].text)
            print(True == re_text[1].is_selected())
        elif Scope =="文库":
            print(True == re_text[2].is_selected())
        elif Scope =="学术":
            print(True == re_text[3].is_selected())
        elif Scope =="播客":
            print(True == re_text[4].is_selected())
        print("text_len:"+str(len(re_text)))
        outline = self.driver.find_element(AppiumBy.ID,"com.metaso:id/dcl_mind")  #结果页大纲按钮
        if not outline:
            print("大纲按钮不存在")
        export =  self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_export")#获取追问按钮
        if not export:
            while(len(export)==0):
                self.driver.swipe(500, 1500, 500, 300, 500)
                export = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_export") #获取追问按钮
        research = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_rearch") #获取模式切换按钮，简洁，深入，研究
        if moshi =="简洁":
            print(research[0].text =="深入")
        elif moshi =="深入" and Scope =="播客":
            print(len(research) == 0)
        elif moshi =="深入":
            print(research[0].text =="研究")
        elif moshi =="研究":
            print(research[0].text == "简洁")
        share = self.driver.find_element(AppiumBy.ID,"com.metaso:id/tv_share")#分享按钮
        export = self.driver.find_element(AppiumBy.ID,"com.metaso:id/tv_export")#追问按钮
        if not share:
            print("分享按钮不存在")
        if not export:
            print("追问按钮不存在")
        source = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_source")#来源/参考文献（全网，文库，播客是来源）
        if not source:
            while(len(source)==0):
                self.driver.swipe(500, 1500, 500, 300, 500)
                source = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_source") #来源/参考文献（全网，文库，播客是来源）
        if Scope =="全网" or Scope =="文库":
            print("来源or参考文献是否存在："+str(source[0].text == "来源"))
        elif Scope =="播客":
            print("来源or参考文献是否存在："+str(source[0].text == "相关播客"))
        else:
            print("来源or参考文献是否存在："+str(source[0].text == "参考文献"))
        
        source_num = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_source_num")#来源数目_底部
        if not source_num:
            while(len(source_num) == 0):
                self.driver.swipe(500, 1500, 500, 300, 500)
                source_num = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/tv_source_num") #来源数目_底部
        print(linke_num.text,source_num[0].text)
        print("来源数目是否相等："+str(linke_num.text == source_num[0].text))
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/cl_source_title").click()#来源展开
        expands = self.driver.find_elements(AppiumBy.XPATH,"//android.widget.LinearLayout")[6]#
        expands.click()
        # print(len(expands))
        # print(expands[-1])
        # expands[1].click()
        # self.driver.find_element(AppiumBy.ID,"tv_source_title").click()
        sleep(2)
        
        # title_text = self.driver.find_element(AppiumBy.ID,"com.metaso:id/tv_title")
        # sleep(2)
        # print(len(title_text.text))
        # print(expands.text==title_text.text)
        self.Return_Btn_Down()

    def serach_work(self):
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/iv_down").click() #点范围下拉框
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/cl_flow").click() #工作流
        subtitles = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView")#0是选择工作流，1是全部，2是最近，3是行业研究
        print("subtitles:"+str(len(subtitles)))
        for i in range(len(subtitles)):
            print(subtitles[i].text)
        subtitle = subtitles[6].text
        subtitles[6].click()#点行业专题研究报告
        sleep(1)
        sublist = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView")
        print(len(sublist))
        for i in range(4,len(sublist)):
            print(sublist[i].text)
        sleep(1)
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/btn_login").click()#点使用
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/et_input").send_keys("半导体")#输入框输入内容
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/btn_login").click()
        btn_stops = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/iv_stop") #停止按钮
        start_time = datetime.now()
        print("btn_stop:"+str(len(btn_stops)))
        while(len(btn_stops) >0 ):
            sleep(1)
            btn_stops = self.driver.find_elements(AppiumBy.ID,"com.metaso:id/iv_stop") #停止按钮
            now_time = datetime.now()
            print("等待了"+str(str(now_time-start_time)[:7:])+"S了")
        self.Wait_Tag_Show("com.metaso:id/iv_mic_bottom",100)
        self.driver.find_element(AppiumBy.ID,"com.metaso:id/dcl_mind").click()
        mulu = self.driver.find_elements(AppiumBy.CLASS_NAME,"android.widget.TextView")
        mulu_list = [mulu[i].text for i in range(len(mulu))]
        print(mulu_list)






# 退出程序，记得之前没敲这段报了一个错误 Error: socket hang up 啥啥啥的忘记了，有兴趣可以try one try
    def Qiut(self):
        self.driver.quit()


if __name__ == "__main__":
    test = Base()
    test.serach_work() 
    # test.Serach("播客","深入","小米")
    # test.user_feedback()
    # test.Serach_Scope("学术","学术")
    # test.Unlogin_serach()
    # test.login("17628235791","fp123456.")
    # test.Check_my()
    # test.login_out()
    # test.Bottom_Btn_Click("首页")
    # test.Bottom_Btn_Click("书架")
    # test.Bottom_Btn_Click("账户")
    #test.Qiut()
    
